@extends("layouts.backend.webadmin")

@section('content')
    <link rel="stylesheet" href="{{env('APP_ROOT')}}/assets/jquery-treetable/css/jquery.treetable.css">

    <!-- 主体部分 -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <a class="btn btn-primary goods-add" href="{{ URL::route('admin.goods.goodscateadd') }}" role="button"><i class="fa fa-plus-square" aria-hidden="true"></i> 增加</a>
                        <a class="btn btn-warning goods-restore" href="{{ URL::route('admin.goods.goodscatelist',['type'=>1]) }}" role="button"><i class="fa fa-trash-o" aria-hidden="true"></i> 回收站</a>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table id="goodsCateTable" class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>分类名称</th>
                                <th>简述</th>
                                <th>增加时间</th>
                                <th>更新时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @forelse ($lists as $list)
                                <tr data-tt-id="{{$list->id}}" data-tt-parent-id="{{$list->pid}}">
                                    <td>{!! $list->pid==0?'<i class="fa fa-caret-down" aria-hidden="true"></i>':'' !!}{{$list->name}}</td>
                                    <td>{{$list->description}}</td>
                                    <td>{{$list->created_at}}</td>
                                    <td>{{$list->updated_at}}</td>
                                    <td>
                                        @if($type==0)
                                            <a class="btn btn-primary goods-update" href="{{ URL::route('admin.goods.goodscateupdate',['id'=>$list->id]) }}" role="button"><i class="fa fa-pencil fa-fw"></i>编辑</a>
                                            <a class="btn btn-danger goods-delete" href="{{ URL::route('admin.goods.goodscatedel',['id'=>$list->id]) }}" role="button"><i class="fa fa-trash-o fa-fw"></i>删除</a>
                                        @else
                                            <a class="btn btn-primary goods-restore" href="{{ URL::route('admin.goods.goodscaterestore',['id'=>$list->id]) }}" role="button"><i class="fa fa-pencil fa-fw"></i>恢复</a>
                                            <a class="btn btn-danger goods-forcedel" href="{{ URL::route('admin.goods.goodscateforcedel',['id'=>$list->id]) }}" role="button"><i class="fa fa-trash-o fa-fw"></i>彻底删除</a>
                                        @endif
                                    </td>
                                </tr>
                            @empty
                                <tr>
                                    <td colspan="6" align="center">暂无数据！</td>
                                </tr>
                            @endforelse
                            </tbody>
                        </table>
{{--                        {{$lists->links()}}--}}
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- 主体部分结束 -->
@stop

@section('javascript-end')
    <script src="{{env('APP_ROOT')}}/assets/jquery-treetable/js/jquery.treetable.js"></script>
    <script>
        $('#goodsCateTable').treetable({"expandable":true,"initialState":"expanded"});
    </script>
@endsection